import Mock from "mockjs"
// 首页轮播图数据
const {swimg}=Mock.mock({
  'swimg|4':[
    {
      img:"@dataImage( '800x400','q_p' )"
    }
  ]
})
Mock.mock("api/getlunbotu","get",()=>{
  return{
    status:0,
    message:swimg
  }
})
// 新闻列表图文数据
const {newsList}=Mock.mock({
  'newsList|10':[
    {
    id:'@increment(1)',
    title:'@ctitle()',
    add_time:'@datetime()',
    abstract:'@cparagraph(30,50)',
    click:'@integer(0,9999)',
    img_url:"@dataImage( '100x100', 'q_p' )"
    }
  ] 
})

Mock.mock('api/getnewslist','get',()=>{
  return{
    status:0,
    message:newsList,
    total:newsList.length
  }
})
// 新闻详情数据
const {newsInfo}=Mock.mock({
  'newsInfo':[
    {
    id:'@increment(1)',
    title:'@ctitle(5,15)',
    click:'@integer(0,9999)',
    add_time:'@datetime()',
    content:'@cparagraph(20,30)',
    
    }
  ] 
})
Mock.mock(/\/api\/getnew/,'get',()=>{
  return{
    status:0,
    message:newsInfo,
    total:newsInfo.length
  }
})
//评论数据
const {comments} =Mock.mock({
  'comments|8':[
    {
      user_name:'@cname',
      add_time:'@datetime()',
      content:'@csentence()',
      img_url:"@dataImage('60x60','T_T')"
    }
  ]
})
Mock.mock(/\/api\/getcomments\/:/,'get',()=>{
  
  return{
    status:0,
    message:comments
  }
})
//添加评论数据
Mock.mock(/\/api\/postcomment/,'post',(options)=>{
  console.log(options)
  const body=JSON.parse(options.body)
  newsList.push(Mock.mock({
    user_name:'匿名',
    add_time:new Date(),
    content:body.text,
    img_url:""
  }))
  console.log(newsList)
  return{
    status:0,
    message:"提交评论成功！"
  }
  
})
//分享图片分类列表数据
const {cat}= Mock.mock({
  cat:[
    {
      title:'全部',
      id:0
    },
    {
      title:'家居生活',
      id:1
    },
    {
      title:'摄影设计',
      id:2
    },
    {
      title:'室内设计',
      id:3
    }

  ]
})
Mock.mock('api/getimgcategory','get',()=>{
  return {
    status:0,
    messages:cat
  }
})
//图片列表数据
const {msg}=Mock.mock({
  'msg|5-9':[
    {
    id:'@increment(0)',
    title:'@ctitle()',
    img_url:"@dataImage( '300x350','')",
    abstract:'@cparagraph(30,50)'
  }
]
})
Mock.mock(/api\/getimages/,'get',()=>{
  return {
    status: 0,
    message: msg
  }
})
//图片缩略图数据
const {images}=Mock.mock({
  'images|2-4':[
    {
      src:"@dataImage('150x200')"
    }
  ]
})
Mock.mock(/api\/getthumimages/,'get',()=>{
  return {
    status: 0,
    message: images

  }
})
//图片详情数据
const {imgInfo}=Mock.mock({
  'imgInfo':[
    {
    id:'@increment(1)',
    title:'@ctitle(9,15)',
    click:'@integer(0,999)',
    add_time:'@datetime()',
    content:'@cparagraph(20,30)',
    
    }
  ] 
})
Mock.mock(/api\/getimageInfo/,'get',()=>{
  return {
    status: 0,
    message: imgInfo
  }
})
//商品列表数据
const {goods}=Mock.mock({
  'goods|11':[
    {
    id:'@increment(1)',
    title:'@ctitle(9,15)',
    add_time:'@datetime()',
    content:'@cparagraph(20,30)',
    click:'@integer(0,999)',
    img_url:"@dataImage( '184x250','')",
    sell_price:'@integer(999,1099)',
    market_price:'@integer(1099,1299)',
    stock_quantity:'@integer(10,70)'
    }
  ] 
})
Mock.mock(/api\/getgoods\?pageindex/,'get',()=>{
  return {
    status: 0,
    message: goods
  }
})
//商品参数区和价格，标题等数据
const {goodsinfo} =Mock.mock({
  'goodsinfo':[{
    id:'@increment(1)',
    title:'@ctitle(9,15)',
    add_time:'@datetime()',
    goods_no:'SD3973042344',
    stock_quantity:'@integer(10,70)',
    market_price:'@integer(1099,1299)',
    sell_price:'@integer(999,1099)',
  }]
})
Mock.mock(/api\/goods\/getinfo/,'get',()=>{
  return{
    status:0,
    message:goodsinfo
  }
})
//商品图文介绍（商品详情）数据
const {goodsdesc}= Mock.mock({
  goodsdesc:[
    {
      title:'@ctitle(9,15)',
      content:'@cparagraph(20,30)',
    }
  ]
})
Mock.mock(/api\/goods\/getdesc/,'get',()=>{
  return{
    status:0,
    message:goodsdesc

  }
})
